It is often the case that we wish to process each of the arguments of a
term in turn.
For example, to decide whether a compound term is ground,
we have to check that each of its arguments is ground.
One possibility is to create a list of those arguments,
and traverse the list processing each element.
Using this approach, a predicate to check for groundness would be
ground(T) :- atomic(T). |
ground(T) :- atomic(T). |
If the arguments of the term do not need to be processed in ascending
order, then it is more efficient to process them in descending order using
arg/3 to access them.
For example, the predicate for groundness checking could be written as
ground(T) :- atomic(T). |